from django.db import models
# 导入时间域
from django.utils import timezone


# Create your models here.
# 基类
class Base(models.Model):
    # 创建时间
    create_time = models.DateTimeField(default=timezone.now, null=True)

    class Meta:
        abstract = True  # 允许继承

class Category(Base):
    name = models.CharField(max_length=200)

    class Meta:
        db_table = 'category'


class Comment(Base):
    uid = models.IntegerField(null=False)
    content = models.CharField(max_length=400)
    reply = models.CharField(max_length=400)
    gid = models.IntegerField()
    class Meta:
        db_table = 'comment'


class Goods(Base):
    name = models.CharField(max_length=200)
    desc = models.CharField(max_length=200, null=True)
    img = models.CharField(max_length=200, null=True)
    video = models.CharField(max_length=200, null=True)
    price = models.IntegerField()
    params = models.CharField(max_length=200)
    flow = models.IntegerField(default=0, null=True)
    info_imgs= models.IntegerField(default=0,null=True)
    cid = models.IntegerField(null=True)

    # 声明表名
    class Meta:
        db_table = 'goods'

class User(models.Model):
    create_time = models.DateTimeField(blank=True, null=True)
    username = models.CharField(max_length=200)
    password = models.CharField(max_length=200)
    img = models.CharField(max_length=200, blank=True, null=True)
    type = models.IntegerField()
    phone = models.CharField(max_length=200, blank=True, null=True)
    num = models.IntegerField(blank=True, null=True)

    class Meta:
        db_table = 'user'


# 轮播图
class Carousel(Base):
    name = models.CharField(max_length=250)
    src = models.CharField(max_length=250)
    img = models.CharField(max_length=250)

    class Meta:
        db_table = 'carousel'